<template>
  <Modal
    v-model="form.visible"
    :width="1000"
    :mask-closable="false"
    :title="'查看信息发布'">
    <Row class="mt30">
      <Col span="16" offset="4">
        <Form ref="form" :model="form.data" :label-width="80">
          <FormItem prop="newsTitle" label="标题">
            {{form.data.newsTitle}}
          </FormItem>
          <FormItem prop="imagePath" label="封面图片">
            <view-img v-if="form.visible" :defaultImageList="defaultImageList"></view-img>
          </FormItem>
          <FormItem prop="newsTime" label="发布时间">
            {{form.data.newsTime | formatDate('YYYY-MM-DD HH:mm:ss') }}
          </FormItem>
          <FormItem prop="newsAuthor" label="作者">
            {{form.data.newsAuthor}}
          </FormItem>
          <FormItem prop="newsSource" label="来源">
            {{form.data.newsSource}}
          </FormItem>
          <FormItem prop="status" label="是否发布">
            {{form.data.status===0 ? '否': '是'}}
          </FormItem>
          <FormItem prop="newsContent" label="内容" class="mt50">
            <div v-html="form.data.newsContent"></div>
          </FormItem>
        </Form>
      </Col>
    </Row>
  </Modal>
</template>

<script>
  import Vue from 'vue'
  import viewImg from '@/components/view-img'

  export default {
    name: 'update-modal',
    props: [
      'form'
    ],
    components: {
      viewImg
    },
    watch: {
      'form.visible': 'onClose'
    },
    methods: {
      onClose (isVisible) {
        if (isVisible) {
          this.defaultImageList = Vue.filter('splitImg')(this.form.data.imagePath || '')
        }
      }
    }
  }
</script>
